<template>
	<view style="padding-bottom: 185rpx;">
		<view class="wr_wrap">
			<view class="index-bg agencies_backg" style="height: 360rpx;"></view>
			<view class="txt_1">我的余额</view>
			<view class="num_1">￥ <span>{{ amount_1 }}</span>{{ amount_2 }}</view>
			<view class="txt_2">提现最低金额1元，每月1~10提现，当月16日到账</view>
			<view class="withdraw">
				<view class="txt_3">提款金额</view>
				<view class="input_num">
					<view class=""><span>￥</span><input type="digit" v-model="formData.withdrawAmount">
					</view>
					<view @click="max_num">全部提现</view>
				</view>
				<view class="txt_4">提款至</view>
				<view class="manner">
					<view>
						<view>
							<image
								src="https://res.jiuzhang-cloud.com/jzy-oss/upload/image/dti-hospital/agencies/Wechat.png"
								mode="scaleToFill" />
						</view>
						<view>微信</view>
						<view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="submit">
			<button @click="submit">提交申请</button>
		</view>
	</view>
</template>

<script>
export default {
	onLoad(option) {
		this.amount_1 = option.amount.slice(0, -3)
		this.amount_2 = option.amount.slice(-3)
		this.formData.busType = option.busType

	},
	data() {
		return {
			amount_1: '00',
			amount_2: '.00',
			formData: {
				busType: '',  //业务类型  机构
				withdrawWay: 2,  //提现方式 微信
				// withdrawUserName: '',  //真实姓名
				// withdrawAccount: '',  //提现账号
				withdrawAmount: ''  //提现金额
			}
		}
	},
	methods: {
		max_num() {
			this.formData.withdrawAmount = this.amount_1 + this.amount_2
		},
		submit() {
			let off_on = true
			Object.keys(this.formData).forEach(key => {
				if (this.formData[key] == '') {
					off_on = false
				}
			});
			if (off_on) {
				if ((this.formData.withdrawAmount) > Number(this.amount_1 + this.amount_2)) {
					uni.showToast({
						title: '不得超过余额',
						icon: 'none'
					});
				} else {
					this.formData.withdrawAmount = Number(this.formData.withdrawAmount)
					this.$api.agenciesWithdraw(this.formData).then(e => {
						const { code, message } = e
						if (code == 200) {
							uni.showToast({
								title: '申请已提交',
								icon: 'none'
							});
							this.gotoRouter('/pages-agencies/withdrawList/withdrawList?busType=' + this.formData.busType + '&activeTab=1')
						} else {
							uni.showToast({
								title: message,
								icon: 'none'
							});
						}
					})
				}
			} else {
				uni.showToast({
					title: '必填项不能为空',
					icon: 'none'
				});
			}
		}
	}
}
</script>

<style lang="less">
@import './WithdrawRequest.less';
</style>
